import { Observable } from './Observable'
export function take(count: number) {
  return (source: any) => {
    let scen = 0
    const observable = new Observable(subscribe => {
      return source.subscribe({
        ...subscribe,
        next: (value: any) => {
          scen++
          if (scen <= count) {
            subscribe.next(value)
            if (scen >= count) {
              subscribe.complete()
            }
          }
        }
      })
    })
    return observable
  }
}